<?php
echo html_writer::start_tag('div', array('id' => 'msglist'));

echo html_writer::start_tag('div', array('id' => 'listtitle'));
echo html_writer::tag('h3', 'Message List');
echo html_writer::end_tag('div');

if (!empty($arrResult))
{
    foreach ($arrResult as $key => $value)
    {
        echo html_writer::start_tag('div', array('class' => 'msg'));

        // блок заголовка и автора
        $author = html_writer::tag('b', $value['author'], array());
        $title = html_writer::tag('b', $value['title'], array());
        echo html_writer::tag('p', 'author:&nbsp;'.$author.'&nbsp;&nbsp;&nbsp;title:&nbsp;'.$title, array());

        // номер связанного сообщения (если существует)
        $response = '';
        if ($value['response'] == 'yes')
        {
            $response = " response on #".$value['targetid'];
        }

        // сслыка на сообщение
        $ref = $DOF->url_im('guestbook', '/index.php', array('section' => 'msg', 'id' => $value['id']));
        $msglink = html_writer::link($ref, 'msg #'.$value['id'].$response, array());
        echo html_writer::tag('p', $msglink, array('class' => 'detail'));

        // текст сообщения
        echo html_writer::tag('div', $value['text'], array('class' => 'text'));

        // дата и комментарии
        $date = html_writer::tag('span', $value['date'], array('class' => 'date'));
        $comments = html_writer::tag('span', '&nbsp;&nbsp;comments:('.$value['commentcnt'].')', array('class' => 'comment'));
        $ref = html_writer::tag('span', '&nbsp;&nbsp;<a ref="#">show</a>', array());

        echo html_writer::tag('p', $date.$comments.$ref, array('class' => 'dateComent'));

        echo html_writer::end_tag('div');

    }
}
else
{
    echo html_writer::start_tag('div', array('class' => 'msg'));

    echo html_writer::tag('p', 'author:&nbsp;<b>System</b>&nbsp;&nbsp;&nbsp;title:&nbsp;<b>Empty List</b>');
    echo html_writer::tag('p', '<a href="#">msg#000</a>', array('class' => 'detail'));
    echo html_writer::tag('p', 'No Messages in List', array('class' => 'text'));

    $date = html_writer::tag('span', 'today', array('class' => 'date'));
    $comments = html_writer::tag('span', 'comments:(none)', array('class' => 'comment'));
    $ref = html_writer::tag('span', '<a ref="#">show</a>', array());

    echo html_writer::tag('p', $date.$comments.$ref, array('class' => 'dateComent'));

    echo html_writer::end_tag('div');
}

echo html_writer::end_tag('div');

?>